package com.audaque.springboot.foshanupload.web.flinkdemo.controller;


import com.audaque.springboot.foshanupload.web.flinkdemo.service.inface.FlinkService;
import lombok.extern.slf4j.Slf4j;
import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.AggregateOperator;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.api.java.operators.FlatMapOperator;
import org.apache.flink.api.java.operators.UnsortedGrouping;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * @author zgb
 * @desc 投产时用main方法运行
 * @date 2023-04-26 09:18:27
 */
@Slf4j
@RestController
@RequestMapping("/flink")
public class FlinkController {


    @Autowired
    private FlinkService flinkService;
    /**
     * 批处理DataSet的处理
     * @throws Exception
     */
    @GetMapping("/textSplitWordCountByDataSet")
    public void textSplitWordCountByDataSet() throws Exception {
        flinkService.textSplitWordCountByDataSet();;
    }

    /**
     *
     * 流处理DataStream的处理
     * @throws Exception
     */
    @GetMapping("/textSplitWordCountByDataStream")
    public void textSplitWordCountByDataStream() throws Exception {
        flinkService.textSplitWordCountByDataStream();

    }


    /**
     *
     * 流处理DataStream的处理
     * @throws Exception
     */
    @GetMapping("/textSplitWordCountByDataStreamFromSocket")
    public void textSplitWordCountByDataStreamFromSocket() throws Exception {
        flinkService.textSplitWordCountByDataStreamFromSocket();
    }




}
